Skip to content

perf(gb): reuse adjacent discard preference on memo hit#69

Merged
TypeThe0ry merged 1 commit into
devfrom
codex/perf-gb-discard-preference-memo
Jul 16, 2026
Merged

perf(gb): reuse adjacent discard preference on memo hit#69
TypeThe0ry merged 1 commit into
devfrom
codex/perf-gb-discard-preference-memo

Conversation

@TypeThe0ry

Copy link
Copy Markdown
Member

Pure performance scope

This PR changes only the GB bot discard preference lookup inside the existing per-index decision loop and adds focused behavior-preservation tests. It does not change the protected benchmark, thresholds, Gradle configuration, bot timing, scoring, evaluator order, or discard tie-breaking.

Candidate

After the previous ting memo optimization, an adjacent duplicate tile can reuse the same non-null ting response while still rescanning the entire hand for the same discard preference.

The candidate reuses only the immediately preceding preference when all of these invariants hold:

  • the current index entered with a non-null exact-tile ting memo hit
  • the current tile is the same exact MahjongTile enum constant as the previous index
  • readyScore is still evaluated before the preference, preserving argument evaluation order
  • every index still constructs and compares its own DiscardChoice

Null evaluator responses remain uncached and recompute at every index. M5 and M5_RED remain distinct; no sameKind comparison is used. Equal candidates still retain the earliest index.

Behavior coverage

Focused tests cover:

  • [M1, M1, M1] retaining the earliest index
  • a null response followed by READY on repeated tiles, including the later memo hit
  • [M5, M5_RED, M5] preventing red-five preference reuse for the exact regular tile
  • the existing null-recomputation and first-remaining-hand invariants

Evidence gate

No performance claim is made from source inspection or local execution. GitHub is the authoritative validator.

Required before merge recommendation:

  • Build and unit-test Actions pass
  • trusted gb-bot A/A drift control passes
  • eight paired AB/BA measurements complete
  • at least two primary metrics pass, including the duplicate-hand must-pass metric
  • all allocation and unique-hand guardrails hold

If the trusted decision is not PASS_OPTIMIZED, this candidate will not be merged.

@TypeThe0ry TypeThe0ry added performance-gb-bot Use the GB bot decision performance profile performance-ab Run the base-owned paired performance gate labels Jul 16, 2026 — with ChatGPT Codex Connector
@TypeThe0ry TypeThe0ry removed the performance-ab Run the base-owned paired performance gate label Jul 16, 2026
@Arbousier1
Arbousier1 force-pushed the codex/perf-gb-discard-preference-memo branch from c5a1779 to 23ff27c Compare July 16, 2026 07:34
@TypeThe0ry TypeThe0ry added the performance-ab Run the base-owned paired performance gate label Jul 16, 2026 — with ChatGPT Codex Connector
@TypeThe0ry
TypeThe0ry marked this pull request as ready for review July 16, 2026 08:35
@TypeThe0ry
TypeThe0ry merged commit 6d012f3 into dev Jul 16, 2026
16 checks passed
@Arbousier1
Arbousier1 deleted the codex/perf-gb-discard-preference-memo branch July 16, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance-ab Run the base-owned paired performance gate performance-gb-bot Use the GB bot decision performance profile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants